class EasyLogLevel implements Comparable<EasyLogLevel> {
  final int value;
  final String name;
  const EasyLogLevel(this.name, this.value);
  static const EasyLogLevel ALL = EasyLogLevel('all', 0);
  static const EasyLogLevel OFF = EasyLogLevel('off', 10);
  static const EasyLogLevel VERBOSE = EasyLogLevel('verbose', 1);
  static const EasyLogLevel DEBUG = EasyLogLevel('debug', 2);
  static const EasyLogLevel INFO = EasyLogLevel('info', 3);
  static const EasyLogLevel WARNING = EasyLogLevel('warning', 4);
  static const EasyLogLevel ERROR = EasyLogLevel('error', 5);
  static const EasyLogLevel FATAL = EasyLogLevel('fatal', 6);
  static const EasyLogLevel CRASH = EasyLogLevel('crash', 7);
  static const EasyLogLevel FLAG = EasyLogLevel('-', 8);
  static const List<EasyLogLevel> LEVELS = [
    ALL,
    OFF,
    VERBOSE,
    DEBUG,
    INFO,
    WARNING,
    ERROR,
    FATAL,
    CRASH,
    FLAG
  ];

  static EasyLogLevel parse(int value) {
    for (var i = 0; i < LEVELS.length; i++) {
      if (value == LEVELS[i].value) {
        return LEVELS[i];
      }
    }
    throw 'not support level';
  }

  @override
  int compareTo(EasyLogLevel other) {
    return value - other.value;
  }

  @override
  int get hashCode {
    return value;
  }

  @override
  String toString() {
    return name;
  }

  @override
  bool operator ==(Object other) {
    return (other is EasyLogLevel) && value == other.value;
  }

  bool operator <(Object other) {
    return (other is EasyLogLevel) && value < other.value;
  }

  bool operator >(Object other) {
    return (other is EasyLogLevel) && value > other.value;
  }

  bool operator <=(Object other) {
    return (other is EasyLogLevel) && value <= other.value;
  }

  bool operator >=(Object other) {
    return (other is EasyLogLevel) && value >= other.value;
  }
}
